def singleton(cls):
    instances = {}
    def get_instance(*args, **kwargs):
        if cls not in instances:
            instances[cls] = cls(*args, **kwargs)
        return instances[cls]
    return get_instance


@singleton
class MyClass:
    def __init__(self, name):
        self.name = name

    def __str__(self):
        return self.name


if __name__ == '__main__':
    obj1 = MyClass('obj1')
    print(obj1)

    obj2 = MyClass('obj2')
    print(obj2)

'''
obj1
obj1
'''